<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title data-i18n="head_title">导航-首页</title>
	<link href="/source/base.css" rel="stylesheet" type="text/css" />
	<link href="/source/tools/bootstrap.css" rel="stylesheet" type="text/css" />
	<link href="/source/plug.css" rel="stylesheet" type="text/css" />

	<style>
		 #logoutButton {
		 position: absolute;
		 right: 100px;
		 top: 4px; /* 添加top属性 */
		 background-color: red;
		 color: white;
		 }
		 #changepwdButton {
		 position: absolute;
		 right: 200px;
		 top: 4px; /* 添加top属性 */
		 background-color: rgb(79, 179, 236);
		 color: white;
		 border-style: none;
		 border-radius: 2px;
		 }
		 #loginButton {
		 position: absolute;
		 right: 300px;
		 top: 4px; /* 添加top属性 */
		 background-color: rgb(79, 179, 236);
		 color: white;
		 }
	 </style>
</head>
<body>
<input id="id-page-name" type="hidden" value="index">
<div class="container min-w300">
	    <button id="loginButton" class="btn btn-primary btn-warning" style=" padding:5px 10px; font-size: 12px;"></button>
		<button id="changepwdButton" style=" padding:5px 10px; font-size: 12px;"   class="bg-yellow-500 hover:bg-yellow-600 text-white font-medium py-1.5 px-2.5 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-yellow-300" onclick="window.location.href='/change_password.html'">修改密码</button>
	    <button id="logoutButton" class="btn btn-primary btn-warning" style=" padding:5px 10px; font-size: 12px;" onclick="logout()">退出登录</button>
		
		<div class="row p0 m0 p20 mb20">
			<h4 class="title f14" data-i18n="head_title">导航页</h4>
			<a id="open-debug" class="btn btn-block btn-main">
				<i class='iconfont mt-1 pr10'>&#xe748;</i>
				<span data-i18n="interfaceDebug">接口测试</span>
			</a>
			<a href="index" class="btn btn-block btn-default mt10">
				<i class='iconfont mt-1 pr10'>&#xe600;</i>
				<span data-i18n="sheetTool">共享表格</span>
			</a>
			<a  href="/uploadfile"class="btn btn-block btn-default mt10">
				<i class='iconfont mt-1 pr10'>&#xe600;</i>
				<span data-i18n="h2Url">上传下载文件</span>
			</a>
			<a  href="/h2"class="btn btn-block btn-default mt10">
				<i class='iconfont mt-1 pr10'>&#xe600;</i>
				<span data-i18n="h2Url">数据库管理</span>
			</a>
			<a  href="/ssh/index"class="btn btn-block btn-default mt10">
				<i class='iconfont mt-1 pr10'>&#xe600;</i>
				<span data-i18n="webssh">开启WebSsh客户端</span>
			</a>
			<a href="/ctoolindex.html"  class="btn btn-block btn-default mt10">
				<i  class='iconfont mt-1 pr10'>&#xe8e8;</i>
				<span data-i18n="offenusetools">常用工具</span>
			</a>
			<a href="/json.html" class="btn btn-block btn-default mt10">
				<i class='iconfont mt-1 pr10'>&#xe600;</i>
				<span data-i18n="jsonTool">Json格式化</span>
			</a>
			<a href="/mahuaindex.html" class="btn btn-block btn-default mt10">
				<i class='iconfont mt-1 pr10'>&#xe600;</i>
				<span data-i18n="MDTool">Makedown编辑器</span>
			</a>
			<a id="set-web-site" class="btn btn-block btn-default mt10">
				<i class='iconfont mt-1 pr10'>&#xe6ae;</i>
				<span data-i18n="setting">系统设置</span>
			</a>
		</div>
	</div>
	<script  src="/source/constant.js"></script>
	<script  src="/source/tools/jquery-1.9.1.min.js"></script>
	<script  src="/source/tools/i18next-1.11.2.min.js"></script>
	<script  src="/source/tools/bootstrap.js?v=200"></script>
	<script  src="/source/tools/jquery.cookie.js"></script>
	<script  src="/source/base-dao.js"></script>
	<script  src="/source/interface-dao.js"></script>
	<script  src="/source/module-dao.js"></script>
	<script  src="/source/plug-function.js"></script>
	<script  src="/source/crapApi.js?v=200"></script>
	<script  src="/source/json.js?v=200"></script>
    
	<script>
	// 退出登录函数
    function logout() {
        $.ajax({
            type: 'POST',
            url: '/user/logout',
            dataType: 'json',
            cache: false,
            headers: {
                'Content-Type': 'application/json;charset=utf-8'
            },
            success: function(response) {
                if (response.code === '0000') { // 假设成功码为 '0000'
                    window.location.href = '/login'; // 跳转到登录页面
                } else {
					console.error('退出登录失败:', response.message);
					window.location.href = '/login'; // 跳转到登录页面
                }
            },
            error: function(error) {
                console.error('请求出错:', error);
				window.location.href = '/login'; // 跳转到登录页面
            }
        });
    }

	function getCookie(name) {
            // 获取当前页面的所有 Cookie 信息
            const cookies = document.cookie.split('; ');
            // 遍历所有的 Cookie
            for (let i = 0; i < cookies.length; i++) {
                const cookie = cookies[i].split('=');
                // 如果找到指定名称的 Cookie
                if (cookie[0] === name) {
                    // 返回该 Cookie 的值
                    return cookie[1];
                }
            }
            // 如果未找到指定名称的 Cookie，返回 null
            return null;
        }

	// 调用 getCookie 函数获取 sheetUserInfo 的值
	const userName = getCookie('sheetUserInfo');
	if (userName) {
		const loginButtonElement = document.getElementById('loginButton');
		loginButtonElement.textContent = userName;
	} else {
		window.location.href = '/login'; 
	}
</script>
</body>
</html>